<extend name="Include:Layout"/>
<block name="title">暑期班报名</block>
<block name="style">
<style>
#lesson_popup header h1{
    font-size: 18px;
    line-height:40px;
    color: #3cc51f;
    font-weight: 400;
    float:left;
    padding-left:15px;
  }
#lesson_popup td{border:solid #ddd; border-width:0px 1px 1px 0px;text-align:center;font-size:14px;line-height:30px;}
#lesson_popup table{border:solid #ddd; border-width:1px 0px 0px 1px;}
#lesson_popup td b{font-size:16px;padding-left:15px;}
  .choice {background-color:#EFEFF4;color:#04BE02;}
  .classlesson td {height:30px;}
 .text-info {color:#999;text-align:center;padding-top:10px;padding-bottom:10px;}
 .enable {color:#999;}
.weui_cells {font-size:14px;}
</style>
</block>

<block name="main">
	<div class="weui_tab">
		<div class="weui_tab_bd container" id="container">
			<div class="weui_cells" style="background:#fff;margin-top:20px;">
				<div class="weui_cell">
		            <div class="weui_cell_hd"><label class="weui_label">学生姓名</label></div>
		            <div class="weui_cell_bd weui_cell_primary">
		                <input class="weui_input" type="text" name="stuname" id="stuname" value="{$_SESSION[_loginUser_home][realname]}" placeholder="请输入学生姓名">
		            </div>
		        </div>
		        <div class="weui_cell">
		            <div class="weui_cell_hd"><label class="weui_label">手机号码</label></div>
		            <div class="weui_cell_bd weui_cell_primary">
		                <input class="weui_input" type="number" name="mobile" id="mobile" value="{$_SESSION[_loginUser_home][mobile]}" readonly pattern="[0-9]*" placeholder="请输入验证码">
		            </div>
		        </div>
			    <div class="weui_cell">
				    <div class="weui_cell_hd"><label class="weui_label">校区</label></div>
				    <div class="weui_cell_bd weui_cell_primary">
				    	<input class="weui_input" id="xiaoqu" type="text" name="xiaoqu" value="" readonly>
				    </div>
				</div>
				<div class="weui_cell" id="summer" style="display:none;">
					<div class="weui_cell_hd"><label class="weui_label">暑期班</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<p>班级名称：<span class="summer_title"></span></p>
						<p>时间：<span class="summer_time"></span></p>
						<p>对象：<span class="summer_duixiang"></span></p>
						<input type="hidden" name="title" value=""/>
						<input type="hidden" name="time" value=""/>
						<input type="hidden" name="duixiang" value=""/>
					</div>
				</div>
				  <div class="weui_cell">
				   	<div class="weui_cell_hd"><label class="weui_label">费用</label></div>
				    <div class="weui_cell_bd weui_cell_primary">
				    	<input class="weui_input" id="fee"  type="num" name="fee"  value="" readonly>
				    </div>
				  </div>
		    </div>
		    <div class="weui_btn_area">
		    	<input type="hidden" name="t" value="{$_GET['t']}"/>
		    	<input type="hidden" name="uid" value="{$_SESSION['_loginUser_home']['uid']}"/>
		        <button class="weui_btn weui_btn_primary btn-tiyanke">确定提交</button>
   		    </div>
		</div>
	</div>
	
<div id="xiaoqu_popup" class="weui-popup-container">
  <div class="weui-popup-modal" style="background:#fff;">
    <div class="toolbar">
          <div class="toolbar-inner">
            <a href="javascript:;" class="picker-button closebtn">关闭</a>
            <h1 class="title" id="xiaoqu_title">选择校区</h1>
          </div>
    </div>
    <div class="modal-content">
	    <div class="weui_panel weui_panel_access" style="margin-top:0;">
	      <div class="weui_panel_bd"> 
	        <div class="weui_cells weui_cells_radio" id="xiaoqu_data">
			 
			</div>
	      </div>
	    </div>
    </div>
  </div>
</div>

<script id="xiaoqu_data_html" type="text/html">
{{each list as value index}}
<div class="weui_cell weui_check_label xiaoqu_class" onclick="get_xiaoqu('{{value.title}}',{{value.id}})" for="xq{{index}}" data-title="{{value.title}}" data-id="{{value.id}}">
	<div class="weui_cell_bd weui_cell_primary">
		<p><span class="cell_xiaoqu">{{value.title}}</span> <br/><span class="cell_xiaoqu_desc">电话：{{value.tel}}</span><br/><span class="cell_xiaoqu_desc">地址：{{value.address}}</span></p>
	</div>
	<div class="weui_cell_ft">
		{{if did == value.id}}
		<input type="radio" class="weui_check" name="radio_xq" checked="checked"  id="xq{{index}}" >
		{{else}}
		<input type="radio" class="weui_check" name="radio_xq"  id="xq{{index}}" >
		{{/if}}
		<span class="weui_icon_checked"></span>
	</div>
</div>
{{/each}}
</script>

<div id="summer_popup" class="weui-popup-container">
	<div class="weui-popup-modal" style="background:#fff;">
		<div class="toolbar">
			<div class="toolbar-inner">
				<a href="javascript:;" class="picker-button closebtn">关闭</a>
				<h1 class="title" id="xiaoqu_title">选择暑期课程</h1>
			</div>
		</div>
		<div class="modal-content">
			<div class="weui_panel weui_panel_access" style="margin-top:0;">
			<div class="weui_panel_bd"> 
				<div class="weui_cells weui_cells_radio" id="summer_data">
				
				</div>
			</div>
			</div>
		</div>
	</div>
</div>
<script id="summer_data_html" type="text/html">
	<div>{{title}}</div>
	<div>开始时间：{{start_time}}</div>
	<div>结束时间：{{end_time}}</div>
	{{each list as value index}}
	<div class="weui_cell weui_check_label xiaoqu_class" onclick="get_summer('{{value.title}}','{{value.time}}','{{value.duixiang}}','{{value.fee}}')" for="xq{{index}}" data-title="{{value.title}}" data-time="{{value.time}}" data-duxiang="{{value.duixiang}}" data-fee = "{{value.fee}}">
		<div class="weui_cell_bd weui_cell_primary">
			<p><span class="cell_xiaoqu">{{value.title}}</span></p>
			<p><span class="cell_xiaoqu_desc">时间：{{value.time}}</span></p>
			<p><span class="cell_xiaoqu_desc">对象：{{value.duixiang}}</span></p>
			<p><span class="cell_xiaoqu_desc">费用：{{value.fee}}</span></p>
		</div>
		<div class="weui_cell_ft">
			{{if kecheng == value.title}}
			<input type="radio" class="weui_check" name="radio_summer" checked="checked"  id="summer{{index}}" >
			{{else}}
			<input type="radio" class="weui_check" name="radio_summer"  id="summer{{index}}" >
			{{/if}}
			<span class="weui_icon_checked"></span>
		</div>
	</div>
	{{/each}}
	</script>
</block>

<block name="script">
<script>
$(".closebtn").click(function(){
	$("#total").val('');
	$.closePopup();
	
})

$("#xiaoqu").click(function(){
	$.showLoading();
	var did = $(this).attr("data-values");
	if(!did) did = 0;
	$.get('/api/ygcl/getxiaoqu_new',function(ret){
		if(ret.status){
			var data = {
				'did':did,
				'list':ret.data
			};
			var html = template("xiaoqu_data_html", data);
			$("#xiaoqu_data").html(html);
			$.hideLoading();
			$("#xiaoqu_popup").popup();
		}else{
			$.alert('无校区','');
		}
	})
})

function get_xiaoqu(title,id){
	$("#xiaoqu").val(title);
	$("#xiaoqu").attr("data-values",id);
	$("#total").val('');
	$.closePopup();
	show_summer(id);
}

function show_summer(did){
	$.showLoading();
	$.post('/summer/api/getsummer',{did:did},function(ret){
		if(ret.status){
			var kecheng = $("input[name=title]").val();
			var data = {
				'title':ret.data.title,
				'start_time':ret.data.start_time,
				'end_time':ret.data.end_time,
				'kecheng':kecheng,
				'list':ret.data.infos
			};
			var html = template("summer_data_html", data);
			$("#summer_data").html(html);
			$.hideLoading();
			$("#summer_popup").popup();
		}else{
			$.alert('无暑假班信息','');
		}
	})
}

function get_summer(title,time,duixiang,fee){
	$(".summer_title").text(title);
	$("input[name=title]").val(title);
	$(".summer_time").text(time);
	$("input[name=time]").text(time);
	$(".summer_duixiang").text(duixiang);
	$("input[name=duixiang]").text(duixiang);
	$("input[name=fee]").val(fee);
	$("#summer").show();
	$.closePopup();
}


$(".btn-tiyanke").click(function(){
	var thisBtn = $(this);
	if(thisBtn.attr('disabled') == 'disabled') {
        return;
	}
	var xiaoqu =$("#xiaoqu").val();
	if(xiaoqu == ''){
		$.alert("请选择校区","");
		return false;
	}
	var fee = $("#fee").val();
	if(fee == ''){
		$.alert("请跟管理员核对金额","");
		return false;
	}
	
	thisBtn.attr('disabled', 'disabled');
	var data = {
			uid:$("input[name=uid]").val(),
			kecheng:$("#class").val(),
			stuname:$("#stuname").val(),
			tel:$("#mobile").val(),
			did:$("#xiaoqu").attr("data-values"),
			xiaoqu:$("#xiaoqu").val(),
			fee:$("#fee").val(),
			type:$("input[name=t]").val(),
		};
	$.post('/api/ygcl/saveqitatiyan',data,function(data){
		thisBtn.removeAttr('disabled');
		if(data.status){
			if(data.data){
				location.href="/weixin/pay/index/id/"+data.data+'.html';
			}else{
				$.toast("提交成功",function(){
					location.reload();
				});
			}
		}
	});
})

</script>
</block>